package com.jvm123.api.util;

/**
 * @author yawn http://jvm123.com
 * 2019/11/22 16:00
 */
public class HexUtil {

    private HexUtil() {}

    private static final char[] hex = "0123456789abcdef".toCharArray();

    public static String toHexString(byte[] bytes) {
        if (null == bytes) {
            return null;
        } else {
            StringBuilder sb = new StringBuilder(bytes.length << 1);
            for (byte aByte : bytes) {
                sb.append(hex[(aByte & 240) >> 4]).append(hex[aByte & 15]);
            }
            return sb.toString();
        }
    }
}
